import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Simon's ride that those alien bastards so rudely keep blowing up
 */
public class Ship  extends Actor
{
    retroWorld theWorld;
    WavPlayer soundBite;
    
    public Ship()
    {
        soundBite = new WavPlayer();
    }

    /**
     * Act - do whatever the Ship wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        //Blow it up
        if (theWorld.getScrollPos() > -390 && theWorld.getScrollPos() < -380)
        {
            theWorld.addObject(new Explosion(), getX(), getY());
            
            //Play proper sound byte
            if (theWorld.getLevel() == 2)
            {
                soundBite.open("1sttimeride.wav");
                soundBite.setLoops(1);
                soundBite.play();
            }
            else //final level
            {
                soundBite.open("2ndtimeride.wav");
                soundBite.setLoops(1);
                soundBite.play();                
            }
            
            theWorld.removeObject(this);
        }

    }    
    
    public void addedToWorld(World world)
    {
        theWorld = (retroWorld)world;
    }
}
